<table width="100%"><tr><td width="20%">
<a href="../index.html">&lt; index</a><br />
<a href="index.html">&lt; 10. Noise generator</a><br />
<a href="noise_perlin.html">&lt; 10.2 Getting Perlin noise</a><br /><br />
</td><td width="60%">
<p align="center">
=====================================<br />
10.3 Getting simplex noise<br />
=====================================<br />
</p></td><td width="20%">
<a href="noise_wavelet.html">&gt; 10.4 Getting wavelet noise</a>
</td></tr></table>
<style type="text/css">
.code { color:#444444; background-color:#EEEEEE;}
pre { color:#444444; background-color:#EEEEEE;}
table.param td { border : 1px solid #000000; }
th { background-color: #44BBFF; color: #FFFFFF }
table.none td { border : 0 }
</style>
This function returns the simplex noise function value between -1.0 and 1.0 at given coordinates.<br />
The simplex noise is much faster than Perlin, especially in 4 dimensions. It has a better contrast too.<br />
<p class="code"><pre>
C++ : float TCODNoise::getSimplex(float *f) const
C   : float TCOD_noise_simplex(TCOD_noise_t noise, float *f)
Py  : noise_simplex(noise, f)
</pre></p>
<table class="param">
<tr><th>Parameter</th><th>Description</th></tr>
<tr><td>noise</td><td>In the C version, the generator handler, returned by the <a href="noise_init.html">initialization</a> function.</td></tr>
<tr><td>f</td><td>An array of coordinates, depending on the generator dimensions (between 1 and 4). The same array of coordinates will always return the same value.</td></tr>
</table>
<br />
Example :<br />
<p class="code"><pre>
C++ : // 1d noise
      TCODNoise * noise1d = new TCODNoise(1);
      float p=0.5f;
      float value = noise1d->getSimplex(&p);
      // 2d noise
      TCODNoise * noise2d = new TCODNoise(2);
      float p[2]={0.5f,0.7f};
      float value = noise2d->getSimplex(p);
C   : /* 1d noise */
      TCOD_noise_t noise1d = TCOD_noise_new(1,TCOD_NOISE_DEFAULT_HURST, TCOD_NOISE_DEFAULT_LACUNARITY,NULL);
      float p=0.5f;
      float value = TCOD_noise_simplex(noise1d,&p);
      /* 2d noise */
      TCOD_noise_t noise2d = TCOD_noise_new(2,TCOD_NOISE_DEFAULT_HURST, TCOD_NOISE_DEFAULT_LACUNARITY,NULL);
      float p[2]={0.5f,0.7f};
      float value = TCOD_noise_simplex(noise2d,p);
Py  : # 1d noise 
      noise1d = libtcod.noise_new(1)
      value = libtcod.noise_simplex(noise1d,[0.5])
      # 2d noise
      noise2d = libtcod.noise_new(2)
      value = libtcod.noise_simplex(noise2d,[0.5,0.7])
</pre></p><br />
This function returns the fbm function value between -1.0 and 1.0 at given coordinates, using fractal hurst and lacunarity defined when the generator has been created.<br />
<p class="code"><pre>
C++ : float TCODNoise::getFbmSimplex(float *f, float octaves) const
C   : float TCOD_noise_fbm_simplex(TCOD_noise_t noise, float *f, float octaves)
Py  : noise_fbm_simplex(noise, f, octaves)
</pre></p>
<table class="param">
<tr><th>Parameter</th><th>Description</th></tr>
<tr><td>noise</td><td>In the C version, the generator handler, returned by the <a href="noise_init.html">initialization</a> function.</td></tr>
<tr><td>f</td><td>An array of coordinates, depending on the generator dimensions (between 1 and 4). The same array of coordinates will always return the same value.</td></tr>
<tr><td>octaves</td><td>Number of iterations. Must be &lt; TCOD_NOISE_MAX_OCTAVES = 128</td></tr>
</table>
<br />
Example :<br />
<p class="code"><pre>
C++ : // 1d fbm
      TCODNoise * noise1d = new TCODNoise(1);
      float p=0.5f;
      float value = noise1d->getFbmSimplex(&p,32.0f);
      // 2d fbm
      TCODNoise * noise2d = new TCODNoise(2);
      float p[2]={0.5f,0.7f};
      float value = noise2d->getFbmSimplex(p,32.0f);
C   : /* 1d fbm */
      TCOD_noise_t noise1d = TCOD_noise_new(1,TCOD_NOISE_DEFAULT_HURST, TCOD_NOISE_DEFAULT_LACUNARITY,NULL);
      float p=0.5f;
      float value = TCOD_noise_fbm_simplex(noise1d,&p,32.0f);
      /* 2d fbm */
      TCOD_noise_t noise2d = TCOD_noise_new(2,TCOD_NOISE_DEFAULT_HURST, TCOD_NOISE_DEFAULT_LACUNARITY,NULL);
      float p[2]={0.5f,0.7f};
      float value = TCOD_noise_fbm_simplex(noise2d,p,32.0f);
Py  : # 1d noise 
      noise1d = libtcod.noise_new(1)
      value = libtcod.noise_fbm_simplex(noise1d,[0.5],32.0)
      # 2d noise
      noise2d = libtcod.noise_new(2)
      value = libtcod.noise_fbm_simplex(noise2d,[0.5,0.7],32.0)
</pre></p><br />
This function returns the turbulence function value between -1.0 and 1.0 at given coordinates, using fractal hurst and lacunarity defined when the generator has been created.<br />
<p class="code"><pre>
C++ : float TCODNoise::getTurbulenceSimplex(float *f, float octaves) const
C   : float TCOD_noise_turbulence_simplex(TCOD_noise_t noise, float *f, float octaves)
Py  : noise_turbulence_simplex(noise, f, octaves)
</pre></p>
<table class="param">
<tr><th>Parameter</th><th>Description</th></tr>
<tr><td>noise</td><td>In the C version, the generator handler, returned by the <a href="noise_init.html">initialization</a> function.</td></tr>
<tr><td>f</td><td>An array of coordinates, depending on the generator dimensions (between 1 and 4). The same array of coordinates will always return the same value.</td></tr>
<tr><td>octaves</td><td>Number of iterations. Must be &lt; TCOD_NOISE_MAX_OCTAVES = 128</td></tr>
</table>
<br />
Example :<br />
<p class="code"><pre>
C++ : // 1d fbm
      TCODNoise * noise1d = new TCODNoise(1);
      float p=0.5f;
      float value = noise1d->getTurbulenceSimplex(&p,32.0f);
      // 2d fbm
      TCODNoise * noise2d = new TCODNoise(2);
      float p[2]={0.5f,0.7f};
      float value = noise2d->getTurbulenceSimplex(p,32.0f);
C   : /* 1d fbm */
      TCOD_noise_t noise1d = TCOD_noise_new(1,TCOD_NOISE_DEFAULT_HURST, TCOD_NOISE_DEFAULT_LACUNARITY,NULL);
      float p=0.5f;
      float value = TCOD_noise_turbulence_simplex(noise1d,&p,32.0f);
      /* 2d fbm */
      TCOD_noise_t noise2d = TCOD_noise_new(2,TCOD_NOISE_DEFAULT_HURST, TCOD_NOISE_DEFAULT_LACUNARITY,NULL);
      float p[2]={0.5f,0.7f};
      float value = TCOD_noise_turbulence_simplex(noise2d,p,32.0f);
Py  : # 1d noise 
      noise1d = libtcod.noise_new(1)
      value = libtcod.noise_turbulence_simplex(noise1d,[0.5],32.0)
      # 2d noise
      noise2d = libtcod.noise_new(2)
      value = libtcod.noise_turbulence_simplex(noise2d,[0.5,0.7],32.0)</pre></p>
